﻿@model ManufacturerModel

@{
    var parentModel = ViewData["Parent"] as ManufacturerListModel;
    var isSingleStoreMode = (bool)ViewBag.IsSingleStoreMode;
    var hasToolbarZoneWidgets = await Display.ZoneHasWidgetsAsync("datagrid_toolbar_omega");
}

<datagrid id="manufacturers-grid" class="h-100"
          allow-resize="true"
          allow-row-selection="hasToolbarZoneWidgets"
          preserve-grid-state="true" preserve-command-state="true"
          allow-column-reordering="true"
          onrowclass="manufacturersGrid_onRowClass">
    <datasource read="@Url.Action("ManufacturerList")" />
    <paging position="Bottom" page-index="1" show-size-chooser="true" />
    <sorting allow-unsort="true" allow-multisort="false">
        <sort by="DisplayOrder" />
    </sorting>
    <toolbar>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.ToggleSearchPanel" type="button" class="btn btn-light btn-icon">
                <i class="fa fa-fw fa-filter"></i>
            </button>
        </toolbar-group>
        <toolbar-group>
            <a asp-action="Create" class="btn btn-primary btn-flat">
                <i class="fa fa-plus"></i>
                <span>@T("Admin.Common.AddNew")…</span>
            </a>
        </toolbar-group>
        <zone name="datagrid_toolbar_omega"></zone>
    </toolbar>
    <search-panel>
        <partial name="_Grid.Manufacturers.Search" model="parentModel" />
    </search-panel>
    <columns>
        <column for="Id" halign="center" visible="false" type="string" />
        <column for="Name" hideable="false" width="2fr">
            <display-template>
                <div class="text-truncate"><a :href="item.row.EditUrl" class="text-truncate">{{ item.value }}</a></div>
            </display-template>
        </column>
        <column for="Published" halign="center" />
        <column for="DisplayOrder" halign="center" />
		@if (!isSingleStoreMode)
		{
			<column for="LimitedToStores" halign="center" />
		}
        <column for="CreatedOn" entity-member="CreatedOnUtc" visible="false" />
        <column for="UpdatedOn" entity-member="UpdatedOnUtc" visible="false" />
    </columns>
</datagrid>

<script sm-target-zone="scripts" data-origin="manufacturers-grid">
    function manufacturersGrid_onRowClass(row) {
        return {
            "text-muted": !row.Published
        };
    }
</script>